<%@page import="com.hellodoctor.util.LConstants"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.text.DateFormat"%>
<%@page import="java.util.Date"%>
<%@page import="com.liferay.portal.service.UserLocalServiceUtil"%>
<%@page import="com.hellodoctor.slayer.service.AppointmentLocalServiceUtil"%>
<%@page import="java.util.ArrayList"%>
<%@page import="com.hellodoctor.slayer.model.Appointment"%>
<%@ include file="/html/common/init.jsp" %>  

<%

List<Appointment> appts = AppointmentLocalServiceUtil.getMyAppointments(user.getUserId());
String[] timeSlots = LConstants.timeSlots;
String[] status = {" ", "Confirmed","Attended","Absent","Cancelled By Doctor","Cancelled By Patient"};
List<Appointment> allAppts = new ArrayList<Appointment>();

allAppts = AppointmentLocalServiceUtil.getMyAppointments(user.getUserId());

%>

<aui:row>
<aui:column columnWidth="50">
<h3> All Appointments </h3>
</aui:column>
<aui:column columnWidth="50">

<a class="right" href="<portlet:renderURL/>"><h4>&laquo; Go Back to Today's Appointment</h4></a>
</aui:column>
</aui:row>
<aui:row>

</aui:row>
<liferay-ui:search-container delta="10" emptyResultsMessage="Sorry. There are no appointments to display." >
	<liferay-ui:search-container-results
			 total="<%= allAppts.size() %>" 
			 results="<%= ListUtil.subList(allAppts,
					 			searchContainer.getStart(), 
					 			searchContainer.getEnd()) %>" />
	<liferay-ui:search-container-row modelVar="appointment" className="Appointment">
		<liferay-ui:search-container-column-text name="Name">
			 <%= UserLocalServiceUtil.getUser(appointment.getPatientId()).getFullName() %>
		</liferay-ui:search-container-column-text>
		<%
		Date date = appointment.getAppointmentDate();
		DateFormat format = new SimpleDateFormat("EEE, d MMM yyyy");
			
		%>
		<liferay-ui:search-container-column-text name="Time"><%= format.format(date) %><br> at <%= timeSlots[appointment.getAppointmentTime()] %> </liferay-ui:search-container-column-text>
		
		<liferay-ui:search-container-column-text name="Time"> <%= timeSlots[appointment.getAppointmentTime()] %> </liferay-ui:search-container-column-text>
		<liferay-ui:search-container-column-text name="Status"> <%= status[appointment.getStatus()] %> </liferay-ui:search-container-column-text>
		<%  %>
		<liferay-ui:search-container-column-jsp name="Actions" path="/html/appointment/actions1.jsp"></liferay-ui:search-container-column-jsp>
	 	 
	</liferay-ui:search-container-row>

	<liferay-ui:search-iterator searchContainer="<%= searchContainer %>" />
</liferay-ui:search-container> 










<%-- <aui:a href="<%=  %>"></aui:a> --%>